﻿using DimensionsHelper.Common.Contracts.Metadata;

namespace DimensionsHelper.Client.WinUi.ViewModels;

public partial class MetadataPropertyViewModel(string name)
    : MetadataNamedViewModel(name, MetadataNamedObjectKind.Property)
{
    [ObservableProperty]
    public partial object? Value
    {
        get;
        set;
    }


    public override string ToString()
    {
        string valueText = Value switch
        {
            string text => $"\"{text}\"",
            _ => Value?.ToString() ?? ""
        };

        return $"{Name} = {valueText}";
    }


    public static MetadataPropertyViewModel FromMetadata(IProperty property)
    {
        MetadataPropertyViewModel obj = new(property.Name)
        {
            Value = property.Value
        };

        return obj;
    }
}